<?php
namespace Admin\Controller;
use Think\Controller;
class ClassController extends BaseController {
    public function index(){
        $this->login_verify();
        $this->display();
    }
    public function classSet(){
    	$news = M("news");
    	$data['title']=$_POST['title'];
    	$data['author']=$_POST['author'];
    	$data['content']=$_POST['content'];
		$data['time']=date('Y-m-d H:i:s');
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     2097152 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
	    $upload->subName  =      'news';
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['img']);
	    if(!$info) {// 上传错误提示错误信息
	        $this->error($upload->getError());
	    }else{// 上传成功 获取上传文件信息
	    	
	    	$data['imgurl']='Uploads/'.$info['savepath'].$info['savename'];
	    	// if($banner->data($data)->add()){
	    	$news = M("news"); // 实例化User对象
		    if($news->add($data)){
	    		$this->success("添加成功",U("Class/index"));
		    }else{
	    		$this->error("添加失败");
		    }
	    }
    }
}